//
//  PersonalCenterViewController.m
//  XingMei
//
//  Created by 姚琪 on 2019/3/20.
//  Copyright © 2019年 钱金军. All rights reserved.
//

#import "PersonalCenterViewController.h"
#import "UIColor+Category.h"
#import "MacroHeader.h"
#import "FilesHeader.h"
#import "NormalTableViewCell.h"
#import "TopUPTableViewCell.h"
#import "UIButton+SSEdgeInsets.h"
#import "MyOrderListViewController.h"//订单页面（整体）

#import "PersonalCenterMessageViewController.h"//消息
#import "AboutUsViewController.h"//关于我们
#import "SetUpViewController.h"//设置
#import "LiuYangViewController.h"


@interface PersonalCenterViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView      *tableV;
@end

@implementation PersonalCenterViewController{
    UIView *headerV;
    UILabel *nameL,*priceL;
    UIImageView *portraitImg;
    NSDictionary *personDict;
    UIImage *saveImg;
    NSMutableArray * arrs;
    UIView *centerV;//会员中心按钮对应的背景视图
    NSMutableArray *btn_arrs;
    UIButton *technicianSelectBtn;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
     [self creatTableView];
    // Do any additional setup after loading the view.
}
-(void)creatTableView{
    _tableV  = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - Height_TabBar) style:UITableViewStyleGrouped];
    _tableV.backgroundColor = [UIColor groupTableViewBackgroundColor];
    if (@available(iOS 11.0, *)) {
        _tableV.contentInsetAdjustmentBehavior = UIApplicationBackgroundFetchIntervalNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = false;
    }
    _tableV.delegate = self;
    _tableV.dataSource = self;
//    _tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(personMessage)];
//    [_tableV.mj_header beginRefreshing];
    [self.view addSubview:_tableV];
    _tableV.showsVerticalScrollIndicator = NO;
    
    [self creatHeaderView];
    [self creatSetBtn];
}
-(UIView *)creatSetBtn{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, Height_NavBar)];
    view.backgroundColor = [UIColor clearColor];
    UIButton *addBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 54, Height_StatusBar, 54,44)];
    [addBtn setImage:[UIImage imageNamed:@"home_icon_9"] forState:0];
    [view addSubview:addBtn];
    addBtn.tag = 101;
    [addBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *messageBtn = [[UIButton alloc]initWithFrame:CGRectMake(addBtn.left - 54, Height_StatusBar, 54,44)];
    messageBtn.tag = 102;
    [messageBtn setImage:[UIImage imageNamed:@"home_icon_8"] forState:0];
    [view addSubview:messageBtn];
    [messageBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    UIButton *setBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, Height_StatusBar, 54,44)];
    setBtn.tag = 103;
    [setBtn setImage:[UIImage imageNamed:@"myself_icon_1"] forState:0];
    [view addSubview:setBtn];
    [setBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    
    
    return view;
}
-(void)creatHeaderView{
    headerV = [[UIView alloc]initWithFrame:CGRectMake(0, Height_NavBar, KScreenWidth, 200)];
    headerV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:headerV];
    //背景
    UIImageView *imgaeV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 110+Height_NavBar)];
    
    imgaeV.image = [UIImage imageNamed:@"myself_bg_1"];
    [headerV addSubview:imgaeV];
    //状态
    UIView  *stutaV = [self creatSetBtn];
    stutaV.xv = 0;
    stutaV.yv = 0;
    [headerV addSubview:stutaV];
    
    
    //头部
    UIView *portraitsV = [[UIView alloc]initWithFrame:CGRectMake(0, Height_NavBar + 10, KScreenWidth, 60)];
    [headerV addSubview:portraitsV];
    
    //头像背景
    UIView *porbgView = [[UIView alloc]initWithFrame:CGRectMake(25, 0, 60, 60)];
    porbgView.backgroundColor = rgba(255, 255, 255, 0.3);
    [portraitsV addSubview:porbgView];
    porbgView.layer.cornerRadius = porbgView.width/2;
    porbgView.layer.masksToBounds = YES;
    
    portraitImg = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 50, 50)];
    //    portraitImg.backgroundColor  = RandomColor;
    portraitImg.layer.cornerRadius = portraitImg.width/2;
    portraitImg.layer.masksToBounds = YES;
    portraitImg.image = [UIImage imageNamed:@"myself_img_20"];
    [porbgView addSubview:portraitImg];
    nameL = [[UILabel alloc]initWithFrame:CGRectMake(porbgView.right + 10, 9, KScreenWidth -porbgView.right - 15 - 105, 17)];
    nameL.font = BoldFont(17);
    nameL.text = @"钱胜强";
    nameL.textColor = rgb(51, 51, 51);
    [portraitsV addSubview:nameL];
    priceL = [[UILabel alloc]initWithFrame:CGRectMake(nameL.xv, nameL.bottom + 10, nameL.width, 11)];
    priceL.font = MediumFont(11);
    priceL.textColor = rgb(102,102,102);
    priceL.text = @"您还不是会员";
    //    priceL.backgroundColor  = RandomColor;
    [portraitsV addSubview:priceL];
    //会员中心按钮
    centerV = [[UIView alloc]initWithFrame:CGRectMake(KScreenWidth - 105, 0, 105,30)];
    centerV.centerYv = porbgView.centerYv;
    [portraitsV addSubview:centerV];
    [centerV.layer addSublayer:[UIColor setGradualChangingColor:centerV fromColor:rgb(211,215,224) toColor:rgb(170,179,198)]];
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:centerV.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = centerV.bounds;
    maskLayer.path = maskPath.CGPath;
    centerV.layer.mask  = maskLayer;
    UIButton *centerBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 0, 95,30)];
    [centerBtn setImage:[UIImage imageNamed:@"myself_icon_30"] forState:0];
    [centerBtn setTitle:@"会员中心  >" forState:0];
    [centerBtn setTitleColor:rgb(255,255,255) forState:0];
    centerBtn.titleLabel.font = MediumFont(12);
    [centerBtn setImagePositionWithType:SSImagePositionTypeLeft spacing:5];
    centerBtn.tag = 104;
    [centerBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    [centerV addSubview:centerBtn];
    
    //暂无预约
    UIView *noreservationV = [self reservationAndEvaluation];
    noreservationV.xv = 15;
    noreservationV.yv = portraitsV.bottom + 10;
    [headerV addSubview:noreservationV];
    //orderView
    UIView *orderV = [[UIView alloc]initWithFrame:CGRectMake(0, noreservationV.bottom, KScreenWidth, 60 + 76*kscW)];
    [headerV addSubview:orderV];
    UILabel *order_lb = [[UILabel alloc]initWithFrame:CGRectMake(20, 15, 73, 16)];
    order_lb.text = @"我的订单";
    order_lb.textColor = rgb(51, 51, 51);
    order_lb.font = MediumFont(16);
    [orderV addSubview:order_lb];
    //底部四个button
    NSArray *titleArr = @[@"待支付",@"待发货",@"待收货",@"已完成"];
    
    float btnWidth   = KScreenWidth/4;
    float btnHeight  = 76*kscW;
    for (int i =0; i<titleArr.count; i++) {
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(btnWidth * i, order_lb.bottom + 9, btnWidth, btnHeight)];
        [orderV addSubview:btn];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, btn.height -  18, btnWidth , 12)];
        label.textColor = rgb(153, 153, 153);
        label.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12.0f];
        label.text = titleArr[i];
        label.textAlignment = NSTextAlignmentCenter;
        [btn addSubview:label];
        
        UIImageView *btnImagV = [[UIImageView alloc]initWithFrame:CGRectMake(37*kscW, label.top - 22 - 10, 22, 22)];
        [btn addSubview:btnImagV];
        UILabel * labs = [[UILabel alloc]initWithFrame:CGRectMake(btnImagV.right-8, btnImagV.top-8, 16, 16)];
        labs.layer.cornerRadius = labs.height/2;
        labs.layer.masksToBounds = YES;
//        labs.textColor = [UIColor whiteColor];
        labs.font = [UIFont systemFontOfSize:11];
        labs.textAlignment = NSTextAlignmentCenter;
//        labs.backgroundColor = [UIColor redColor];
        [btn addSubview:labs];
        [arrs addObject:labs];
        btn.tag = 100 + i;
        [btn addTarget:self action:@selector(allBtnTipControlEven:) forControlEvents:UIControlEventTouchUpInside];
        switch (i) {
            case 0:{
                btnImagV.image = [UIImage imageNamed:@"myself_icon_5"];
                break;}
            case 1:{
                btnImagV.image = [UIImage imageNamed:@"myself_icon_6"];
                break;}
            case 2:{
                btnImagV.image = [UIImage imageNamed:@"myself_icon_7"];
                break;}
            case 3:{
                btnImagV.image = [UIImage imageNamed:@"myself_icon_8"];
                break;
            }
            default:
                break;
        }
        
        
    }
    headerV.height =orderV.bottom + 5;
    
    _tableV.tableHeaderView = headerV;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0 ) {
        return 5;
    }
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        NormalTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        if (!cell) {
            cell = [[NormalTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        }
        if (indexPath.row == 0) {
            cell.normalLable.text = @"我的团队";
            cell.subLable.text = @"100人";
        }else if (indexPath.row == 1){
            cell.normalLable.text = @"我的售后";
            cell.subLable.text = @"200单";
        }else if (indexPath.row == 2){
            cell.normalLable.text = @"消费劵";
            cell.subLable.text = @"10000";
        }else if (indexPath.row == 3){
            cell.normalLable.text = @"佣金";
            cell.subLable.text = @"2003";
        }else{
            TopUPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
            if (!cell) {
                cell = [[TopUPTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"];
            }
            cell.top_upBtn.tag = 106;
            [cell.top_upBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
            cell.normalLable.text = @"余额";
            cell.subLable.text = @"剩余：2003";
           return cell;
        }
        return cell;
    }
    NormalTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell_2"];
    if (!cell) {
        cell = [[NormalTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell_2"];
    }
    if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            cell.normalLable.text = @"关于我们";
        }else{
            cell.normalLable.text = @"投诉与建议";

        }
    }
    return cell;
    
    
}
#pragma mark- 高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 8;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]init];
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]init];
    return view;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            
        }else if (indexPath.row == 1){
            
        }else if (indexPath.row == 2){
            
        }else if (indexPath.row == 3){
            
        }else if (indexPath.row == 4){
            
        }
    }else{
        if (indexPath.row == 0) {
            //关于我们
            AboutUsViewController *controller = [[AboutUsViewController alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
        }else{
            //投诉与建议
            LiuYangViewController *controller = [[LiuYangViewController alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
        }
    }
}
#pragma mark- 暂无预约
-(UIView *)NoReservation{
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth-30, 80)];
    view.layer.cornerRadius = 5;
    view.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1.0f] CGColor];
    view.layer.shadowColor = rgb(242,242,242).CGColor;
    view.layer.shadowOpacity = 1;
    view.layer.shadowOffset = CGSizeMake(0, 3);
    view.layer.shadowRadius = 5;
    UILabel *titlelb = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, 80, 15)];
    [view addSubview:titlelb];
    titlelb.font = BoldFont(14);
    titlelb.text = @"我的预约";
    titlelb.textColor = rgb_51;
    
    UIButton *centerBtn = [[UIButton alloc]initWithFrame:CGRectMake(view.width - 60-10, 20, 60,14)];
    [centerBtn setImage:[UIImage imageNamed:@"myself_icon_4"] forState:0];
    [centerBtn setTitle:@"预约历史" forState:0];
    [centerBtn setTitleColor:rgb_153 forState:0];
    centerBtn.titleLabel.font = MediumFont(12);
    [centerBtn setImagePositionWithType:SSImagePositionTypeRight spacing:5];
    centerBtn.tag = 105;
    [centerBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:centerBtn];
    titlelb.centerYv = centerBtn.centerYv;
    
    UILabel *contentlb = [[UILabel alloc]initWithFrame:CGRectMake(0, titlelb.bottom +10, view.width, 12)];
    [view addSubview:contentlb];
    contentlb.textAlignment = NSTextAlignmentCenter;
    contentlb.font = MediumFont(12);
    contentlb.text = @"暂无预约";
    contentlb.textColor = rgb(255,116,2);

    return view;
}
#pragma mark- 有预约
-(UIView *)reservationAndHaveAddressWherther:(BOOL)isbool{
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth-30, 140)];
    view.layer.cornerRadius = 5;
    view.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1.0f] CGColor];
    view.layer.shadowColor = rgb(242,242,242).CGColor;
    view.layer.shadowOpacity = 1;
    view.layer.shadowOffset = CGSizeMake(0, 3);
    view.layer.shadowRadius = 5;
    UILabel *titlelb = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, 80, 15)];
    [view addSubview:titlelb];
    titlelb.font = BoldFont(14);
    titlelb.text = @"我的预约";
    titlelb.textColor = rgb_51;
    
    UIButton *centerBtn = [[UIButton alloc]initWithFrame:CGRectMake(view.width - 60-10, 20, 60,14)];
    [centerBtn setImage:[UIImage imageNamed:@"myself_icon_4"] forState:0];
    [centerBtn setTitle:@"预约历史" forState:0];
    [centerBtn setTitleColor:rgb_153 forState:0];
    centerBtn.titleLabel.font = MediumFont(12);
    [centerBtn setImagePositionWithType:SSImagePositionTypeRight spacing:5];
    centerBtn.tag = 105;
    [centerBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:centerBtn];
    titlelb.centerYv = centerBtn.centerYv;
    
    UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(15, titlelb.bottom + 15, 75, 75)];
    imgV.layer.cornerRadius = 5;
    imgV.backgroundColor = RandomColor;
    [view addSubview:imgV];
    //服务内容
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(imgV.right + 10, imgV.top + 4, 50, 11)];
    [view addSubview:label];
    label.font = MediumFont(11);
    label.text = @"服务内容:";
    label.textColor = rgb_153;
    
    
    
    UILabel *serviceContentlb = [[UILabel alloc]initWithFrame:CGRectMake(label.right + 5, label.yv, view.width - label.right - 10 - 35, 11)];
    [view addSubview:serviceContentlb];
    serviceContentlb.font = MediumFont(11);
    serviceContentlb.text = @"洗剪吹";
    serviceContentlb.textColor = rgb_51;
    
    
    //服务技术
    UILabel *label_1 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label.bottom + 5, label.width, 11)];
    [view addSubview:label_1];
    label_1.font = MediumFont(11);
    label_1.text = @"服务技师:";
    label_1.textColor = rgb_153;
    
    UILabel *serviceTechnicianlb = [[UILabel alloc]initWithFrame:CGRectMake(label_1.right + 5, label_1.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceTechnicianlb];
    serviceTechnicianlb.font = MediumFont(10);
    serviceTechnicianlb.text = @"kiven";
    serviceTechnicianlb.textColor = rgb_51;
    //预约门店
    UILabel *label_2 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label_1.bottom + 5, label.width, 11)];
    [view addSubview:label_2];
    label_2.font = MediumFont(11);
    label_2.text = @"预约门店:";
    label_2.textColor = rgb_153;
    
    UILabel *serviceAddresslb = [[UILabel alloc]initWithFrame:CGRectMake(label_2.right + 5, label_2.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceAddresslb];
    serviceAddresslb.font = MediumFont(11);
    if (isbool) {
        serviceAddresslb.text = @"盘古造型(经开万达店)";
    }else{
       serviceAddresslb.text = @"无";
    }
    serviceAddresslb.textColor = rgb_51;
    //预约时间
    UILabel *label_3 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label_2.bottom + 5, label.width, 11)];
    [view addSubview:label_3];
    label_3.font = MediumFont(11);
    label_3.text = @"预约时间:";
    label_3.textColor = rgb_153;
    
    UILabel *serviceTimelb = [[UILabel alloc]initWithFrame:CGRectMake(label_3.right + 5, label_3.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceTimelb];
    serviceTimelb.font = MediumFont(11);
    serviceTimelb.text = @"2019年5月15日 14:00";
    
    serviceTimelb.textColor = rgb_51;
    //备注按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(view.width - 15 - 20 , label.yv, 35, 11);
    UILabel *buttonlb = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,button.width , button.height)];
    [button addSubview:buttonlb];
    buttonlb.font = MediumFont(11);
    buttonlb.text = @"备注";
    
    buttonlb.textColor = rgb_153;
    [view addSubview:button];
    button.tag = 107;
    [button addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    //电话
    UIButton *telBtn = [[UIButton alloc]initWithFrame:CGRectMake(button.xv, button.bottom + 8, 20, 20)];
    [view addSubview:telBtn];
    UIImageView *telImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
    telImageV.image = [UIImage imageNamed:@"technician_icon_2"];
    [telBtn addSubview:telImageV];
    telBtn.tag = 108;
    [telBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    //地址
    UIButton *addressBtn = [[UIButton alloc]initWithFrame:CGRectMake(button.xv, telBtn.bottom + 8, 20, 20)];
    [view addSubview:addressBtn];
    addressBtn.hidden = YES;
    if (isbool) {
        addressBtn.hidden = NO;
    }else{
        addressBtn.hidden = YES;
    }
    UIImageView *addressImageV = [[UIImageView alloc]initWithFrame:CGRectMake(addressBtn.width - 12, 3, 12, 14)];
    addressImageV.image = [UIImage imageNamed:@"barber_icon_1"];
    [addressBtn addSubview:addressImageV];
    addressBtn.tag = 108;
    [addressBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    
    
    return view;

}

#pragma mark- 预约评价
-(UIView *)reservationAndEvaluation{
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth-30, 182)];
    view.layer.cornerRadius = 5;
    view.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1.0f] CGColor];
    view.layer.shadowColor = rgb(242,242,242).CGColor;
    view.layer.shadowOpacity = 1;
    view.layer.shadowOffset = CGSizeMake(0, 3);
    view.layer.shadowRadius = 5;
    UILabel *titlelb = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, 80, 15)];
    [view addSubview:titlelb];
    titlelb.font = BoldFont(14);
    titlelb.text = @"我的预约";
    titlelb.textColor = rgb_51;
    
    UIButton *centerBtn = [[UIButton alloc]initWithFrame:CGRectMake(view.width - 60-10, 20, 60,14)];
    [centerBtn setImage:[UIImage imageNamed:@"myself_icon_4"] forState:0];
    [centerBtn setTitle:@"预约历史" forState:0];
    [centerBtn setTitleColor:rgb_153 forState:0];
    centerBtn.titleLabel.font = MediumFont(12);
    [centerBtn setImagePositionWithType:SSImagePositionTypeRight spacing:5];
    centerBtn.tag = 105;
    [centerBtn addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:centerBtn];
    titlelb.centerYv = centerBtn.centerYv;
    
    UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(15, titlelb.bottom + 15, 75, 75)];
    imgV.layer.cornerRadius = 5;
    imgV.backgroundColor = RandomColor;
    [view addSubview:imgV];
    //服务内容
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(imgV.right + 10, imgV.top + 4, 50, 11)];
    [view addSubview:label];
    label.font = MediumFont(11);
    label.text = @"服务内容:";
    label.textColor = rgb_153;
    
    
    
    UILabel *serviceContentlb = [[UILabel alloc]initWithFrame:CGRectMake(label.right + 5, label.yv, view.width - label.right - 10 - 35, 11)];
    [view addSubview:serviceContentlb];
    serviceContentlb.font = MediumFont(11);
    serviceContentlb.text = @"洗剪吹";
    serviceContentlb.textColor = rgb_51;
    
    
    //服务技术
    UILabel *label_1 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label.bottom + 5, label.width, 11)];
    [view addSubview:label_1];
    label_1.font = MediumFont(11);
    label_1.text = @"服务技师:";
    label_1.textColor = rgb_153;
    
    UILabel *serviceTechnicianlb = [[UILabel alloc]initWithFrame:CGRectMake(label_1.right + 5, label_1.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceTechnicianlb];
    serviceTechnicianlb.font = MediumFont(10);
    serviceTechnicianlb.text = @"kiven";
    serviceTechnicianlb.textColor = rgb_51;
    //预约门店
    UILabel *label_2 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label_1.bottom + 5, label.width, 11)];
    [view addSubview:label_2];
    label_2.font = MediumFont(11);
    label_2.text = @"预约门店:";
    label_2.textColor = rgb_153;
    
    UILabel *serviceAddresslb = [[UILabel alloc]initWithFrame:CGRectMake(label_2.right + 5, label_2.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceAddresslb];
    serviceAddresslb.font = MediumFont(11);
    serviceAddresslb.text = @"盘古造型(经开万达店)";
    
    serviceAddresslb.textColor = rgb_51;
    //预约时间
    UILabel *label_3 = [[UILabel alloc]initWithFrame:CGRectMake(label.xv, label_2.bottom + 5, label.width, 11)];
    [view addSubview:label_3];
    label_3.font = MediumFont(11);
    label_3.text = @"预约时间:";
    label_3.textColor = rgb_153;
    
    UILabel *serviceTimelb = [[UILabel alloc]initWithFrame:CGRectMake(label_3.right + 5, label_3.yv,serviceContentlb.width , 11)];
    [view addSubview:serviceTimelb];
    serviceTimelb.font = MediumFont(11);
    serviceTimelb.text = @"2019年5月15日 14:00";
    
    serviceTimelb.textColor = rgb_51;
    //备注按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(view.width - 15 - 20 , label.yv, 35, 11);
    UILabel *buttonlb = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,button.width , button.height)];
    [button addSubview:buttonlb];
    buttonlb.font = MediumFont(11);
    buttonlb.text = @"备注";
    
    buttonlb.textColor = rgb_153;
    [view addSubview:button];
    button.tag = 107;
    [button addTarget:self action:@selector(statusViewBtnEvents:) forControlEvents:UIControlEventTouchUpInside];
    
    //技师评价
    UIView *technicianView = [[UIView alloc]initWithFrame:CGRectMake(0, imgV.bottom, view.width, 50)];
    [view addSubview:technicianView];
    CGFloat btnWidth = (view.width - imgV.right - 10)/5;
    NSArray *titles = @[@"比较差",@"不太好",@"一般",@"满意",@"非常满意"];
    
    btn_arrs = [NSMutableArray array];
    for (int i = 0; i<titles.count; i++) {
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(imgV.right + (i*btnWidth), 0, btnWidth, 50)];
        [technicianView addSubview:btn];
        btn.titleLabel.font = MediumFont(9);
        [btn setTitle:titles[i] forState:0];
        [btn setTitleColor:rgb_153 forState:0];
        switch (i) {
            case 0:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_1_d"] forState:0];
                break;
            case 1:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_2_d"] forState:0];
                break;
            case 2:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_3_d"] forState:0];
                break;
            case 3:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_4_d"] forState:0];
                break;
            case 4:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_5_d"] forState:0];
                break;
            default:
                break;
        }
        if (i == 0) {
            technicianSelectBtn = btn;
        }
        btn.tag = 1000 + i;
        [btn setImagePositionWithType:SSImagePositionTypeTop spacing:10];
        [btn_arrs addObject:btn];
        [btn addTarget:self action:@selector(technicianEvaluationEvents:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    UILabel *technicianEvluationlb = [[UILabel alloc]initWithFrame:CGRectMake(30, 20,50 , 11)];
    [technicianView addSubview:technicianEvluationlb];
    technicianEvluationlb.font = MediumFont(11);
    technicianEvluationlb.text = @"技师评价:";
    
    technicianEvluationlb.textColor = rgb_51;
    
    return view;
}

#pragma mark-  导航栏按钮事件
-(void)statusViewBtnEvents:(UIButton *)btn{
    NSLog(@"button.tag == %li",btn.tag);
    if (btn.tag == 101) {
        //扫描页面
    }else if (btn.tag == 102){
        //消息页面
        PersonalCenterMessageViewController *controller = [[PersonalCenterMessageViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if(btn.tag == 103){
        //设置
        SetUpViewController *controller = [[SetUpViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (btn.tag == 104){
        //会员中心
    }else if (btn.tag == 105){
        //预约历史
    }else if (btn.tag == 106){
        //充值
    }else if (btn.tag == 107){
        //备注
    }else if (btn.tag == 108){
        //电话
    }else if (btn.tag == 109){
        //地址导航
    }
}
#pragma mark- 所有订单事件
-(void)allBtnTipControlEven:(UIButton *)sender{
    MyOrderListViewController *controller = [[MyOrderListViewController alloc]init];
    if (sender.tag >=100) {
        switch (sender.tag) {
            case 100:
                controller.flag = 1;
                break;
            case 101:{
                controller.flag = 2;
                break;
            }
            case 102:
                controller.flag = 3;
                break;
            case 103:
                controller.flag = 4;
                break;
            default:
                break;
        }
        [self.navigationController pushViewController:controller animated:YES];
    }
    
}
#pragma mark- 技师评价事件
-(void)technicianEvaluationEvents:(UIButton *)sender{
    NSInteger tag = sender.tag - 1000;
    [self restoreButtonBackground];//恢复数组中按键的背景颜色
    UIButton *btn = btn_arrs[tag];
    switch (tag) {
        case 0:{
            [btn setImage:[UIImage imageNamed:@"evaluate_icon_1_s"] forState:0];
            break;}
        case 1:
            [btn setImage:[UIImage imageNamed:@"evaluate_icon_2_s"] forState:0];
            break;
        case 2:
            [btn setImage:[UIImage imageNamed:@"evaluate_icon_3_s"] forState:0];
            break;
        case 3:
            [btn setImage:[UIImage imageNamed:@"evaluate_icon_4_s"] forState:0];
            break;
        case 4:
            [btn setImage:[UIImage imageNamed:@"evaluate_icon_5_s"] forState:0];
            break;
        default:
            break;
    }
    
    technicianSelectBtn = btn;
    
    
    
    
}
-(void)restoreButtonBackground{
    for (int i =0 ; i<btn_arrs.count; i++) {
        UIButton *btn = btn_arrs[i];
        switch (i) {
            case 0:{
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_1_d"] forState:0];
                break;}
            case 1:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_2_d"] forState:0];
                break;
            case 2:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_3_d"] forState:0];
                break;
            case 3:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_4_d"] forState:0];
                break;
            case 4:
                [btn setImage:[UIImage imageNamed:@"evaluate_icon_5_d"] forState:0];
                break;
            default:
                break;
        }
        
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
